/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package com.gxuwz.byssxsys.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.gxuwz.byssxsys.model.*;
import com.gxuwz.byssxsys.dao.*;
import com.gxuwz.byssxsys.service.*;
import com.gxuwz.byssxsys.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

@Repository
public class TeacherBaseInfoDao extends BaseHibernateDao<TeacherBaseInfo,java.lang.Integer>{

	public Class getEntityClass() {
		return TeacherBaseInfo.class;
	}
	
	public Page findPage(TeacherBaseInfoQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from TeacherBaseInfo t where 1=1 "
			  	+ "/~ and t.teachNo1 = {teachNo1} ~/"
			  	+ "/~ and t.teachName2 = {teachName2} ~/"
			  	+ "/~ and t.teachSex3 = {teachSex3} ~/"
			  	+ "/~ and t.teachXi4 = {teachXi4} ~/"
			  	+ "/~ and t.teachIdcard5 = {teachIdcard5} ~/"
			  	+ "/~ and t.teachMobilePhone6 = {teachMobilePhone6} ~/"
			  	+ "/~ and t.teachEmail7 = {teachEmail7} ~/"
			  	+ "/~ and t.teachSpeciality8 = {teachSpeciality8} ~/"
			  	+ "/~ and t.teachAwards9 = {teachAwards9} ~/"
			  	+ "/~ and t.teachPassword10 = {teachPassword10} ~/"
			  	+ "/~ and t.teachRemark11 = {teachRemark11} ~/"
			  	+ "/~ and t.teachNumber12 = {teachNumber12} ~/"
			  	+ "/~ and t.teachPublishPapers14 = {teachPublishPapers14} ~/"
			  	+ "/~ and t.teachPastPerformance15 = {teachPastPerformance15} ~/"
				+ "/~ order by [sortColumns] ~/";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
        StringBuilder sql2 = new StringBuilder("select t from TeacherBaseInfo t where 1=1 ");
        if(isNotEmpty(query.getId())) {
            sql2.append(" and  t.id = :id ");
        }
        if(isNotEmpty(query.getTeachNo1())) {
            sql2.append(" and  t.teachNo1 = :teachNo1 ");
        }
        if(isNotEmpty(query.getTeachName2())) {
            sql2.append(" and  t.teachName2 = :teachName2 ");
        }
        if(isNotEmpty(query.getTeachSex3())) {
            sql2.append(" and  t.teachSex3 = :teachSex3 ");
        }
        if(isNotEmpty(query.getTeachXi4())) {
            sql2.append(" and  t.teachXi4 = :teachXi4 ");
        }
        if(isNotEmpty(query.getTeachIdcard5())) {
            sql2.append(" and  t.teachIdcard5 = :teachIdcard5 ");
        }
        if(isNotEmpty(query.getTeachMobilePhone6())) {
            sql2.append(" and  t.teachMobilePhone6 = :teachMobilePhone6 ");
        }
        if(isNotEmpty(query.getTeachEmail7())) {
            sql2.append(" and  t.teachEmail7 = :teachEmail7 ");
        }
        if(isNotEmpty(query.getTeachSpeciality8())) {
            sql2.append(" and  t.teachSpeciality8 = :teachSpeciality8 ");
        }
        if(isNotEmpty(query.getTeachAwards9())) {
            sql2.append(" and  t.teachAwards9 = :teachAwards9 ");
        }
        if(isNotEmpty(query.getTeachPassword10())) {
            sql2.append(" and  t.teachPassword10 = :teachPassword10 ");
        }
        if(isNotEmpty(query.getTeachRemark11())) {
            sql2.append(" and  t.teachRemark11 = :teachRemark11 ");
        }
        if(isNotEmpty(query.getTeachNumber12())) {
            sql2.append(" and  t.teachNumber12 = :teachNumber12 ");
        }
        if(isNotEmpty(query.getTeachPublishPapers14())) {
            sql2.append(" and  t.teachPublishPapers14 = :teachPublishPapers14 ");
        }
        if(isNotEmpty(query.getTeachPastPerformance15())) {
            sql2.append(" and  t.teachPastPerformance15 = :teachPastPerformance15 ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sql2.append(" order by :sortColumns ");
        }	
        
		return pageQuery(sql,query);
	}
	
	public TeacherBaseInfo getByTeachNo1(java.lang.String v) {
		return (TeacherBaseInfo) findByProperty("teachNo1",v);
	}	

}
